﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "UiBuilder.h"
//UI相关头文件
#include "IApplication.h"
#include "IMainWindow.h"
#include "IRibbonSystemButton.h"
#include "IRibbon.h"
#include "IRibbonQuickAccessBar.h"
#include "IStatusBar.h"
#include "IStatusBarPanel.h"
//Ribbon相关头文件
#include "IControlDefinitionLibrary.h"
#include "IRibbonPage.h"
#include "IRibbonGroup.h"
#include "ICommandButtonDefinition.h"
#include "ICommandButtonMenuDefinition.h"
#include "IComboBoxDefinition.h"
#include "IRadioButtonGroupDefinition.h"
#include "ILabelDefinition.h"
#include "ICheckBoxGroupDefinition.h"
#include "IRibbonContextualPage.h"
//可见性、可用性
#include "IPageHandler.h"
#include "IQuickAccessBarHandler.h"
#include "ICheckBoxGroupHandler.h"
#include "ICheckBoxGroupEventArgs.h"
//视图文档相关头文件
#include "IUiDocumentViewManager.h"
#include "IUiViewEvent.h"
#include "IUiDocumentEvent.h"
#include "UiPlatformUtils.h"
//命令相关头文件
#include "CommandIds.h"
#include "ICommandManager.h"
#include "ICommand.h"
#include "CommandParameters.h"
//工具类相关头文件，如国际化、提示信息等
#include "TranslatorManager.h"
#include "DebugMessage.h"

//测试构件库需求
#include "IFamilyFile.h"
#include "IProductBasicInformation.h"

#include "IUiManager.h"
#include "ICommandMenuItemDefinition.h"

#include "EnableCompileWarning_The_LAST_IncludeInCpp.h" 

using namespace gcmp;
using namespace Sample;

namespace Sample
{
    class PageHandler : public gcmp::IPageHandler
    {
    public:
        virtual bool IsVisible() const override
        {
            return true;
        }
        virtual bool IsEnabled() const override
        {
            return true;
        }
    };

    class FilePageHandler : public PageHandler
    {
    public:
        virtual bool IsVisible() const override
        {
            return true;
        }
    };

    class QuickAccessBarHandler : public IQuickAccessBarHandler
    {
    public:
        virtual bool IsVisible() const override
        {
            return true;
        }
    };

    class CheckBoxGroupHandler : public ICheckBoxGroupHandler
    {
    public:
        virtual bool IsVisible(const std::wstring& id) const override
        {
            ICommand *pCommand = ICommandManager::Get()->GetCommand(id);
            if (pCommand)
            {
                return pCommand->IsVisible();
            }
            return false;
        }

        virtual bool IsEnabled(const std::wstring& id) const override
        {
            ICommand *pCommand = ICommandManager::Get()->GetCommand(id);
            if (pCommand)
            {
                return pCommand->IsEnabled();
            }
            return false;
        }

        virtual void On(ICheckBoxGroupEventArgs* pArgs) override
        {
            DBG_WARN_AND_RETURN_VOID_UNLESS(pArgs, L"pArgs参数不能为空", L"GDMP", L"2023-09-30");
            if (pArgs->GetType() == CheckBoxGroupEventType::CheckBoxStateChanged)
            {
                std::pair<std::wstring, CheckState> checkBoxState = pArgs->GetStateChangedCheckBoxIdAndState();
                std::wstring &commandId = checkBoxState.first;
                bool isChecked = (checkBoxState.second == CheckState::Checked);
                CommandParameters commandParams;
                commandParams[L"IsChecked"] = CommandParameterValue(isChecked);
                ICommandManager::Get()->SendCommand(commandId, commandParams);
            }
        }
    };
}


PlatformUiBuilder::PlatformUiBuilder()
{
    
}

void PlatformUiBuilder::Build() const
{
    IMainWindow* pMainWnd = IMainWindow::GetMainWindow();
    DBG_WARN_AND_RETURN_VOID_UNLESS(pMainWnd, L"获取主窗口失败", L"GDMP", L"2023-09-30");
    IRibbon* pRibbon = pMainWnd->GetRibbon();
    //测试构件库需求

    //系统菜单
    BuildSystemButton(pRibbon);
    //引用命令
    BuildReferencedCommand();
    //Ribbon页面
    BuildPages(pRibbon);
    //快速访问栏
    BuildLeftQuickAccessBar(pRibbon);
    BuildRightQuickAccessBar(pRibbon);
    //状态栏
    BuildStatusBar(pMainWnd);
}

void PlatformUiBuilder::BuildSystemButton(gcmp::IRibbon* pRibbon) const
{
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRibbon, L"获取RibbonBar失败", L"GDMP", L"2023-09-30");
    IRibbonSystemButton* pRibbonSystemButton = pRibbon->GetSystemButton();
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRibbonSystemButton, L"获取SystemButton失败", L"GDMP", L"2023-09-30");
    pRibbonSystemButton->SetTooltip(GBMP_TR(L"GDMP示例程序"));
    pRibbonSystemButton->SetIcon(L":/images/Application/64x64.png");
    pRibbonSystemButton->SetText(GBMP_TR(L"GDMP示例程序"));
}

void  PlatformUiBuilder::BuildReferencedCommand() const
{
    //将引用的命令加入控件库
    OwnerPtr<ICommandButtonDefinition> opNewFileDefinition =
        ICommandButtonDefinition::Create(ID_CMD_NEW_FILE,GBMP_TR(L"新建"), GBMP_TR(L"新建(Ctrl+N)"), ID_CMD_NEW_FILE, L":/images/New/48x48.png");
    IControlDefinitionLibrary::Get()->AddControlDefinition(TransferOwnership(opNewFileDefinition));

    OwnerPtr<ICommandButtonDefinition> opOpenFileDefinition = 
        ICommandButtonDefinition::Create(ID_CMD_OPEN_FILE, GBMP_TR(L"打开"), GBMP_TR(L"打开(Ctrl+O)"), ID_CMD_OPEN_FILE, L":/images/Open/48x48.png");
    IControlDefinitionLibrary::Get()->AddControlDefinition(TransferOwnership(opOpenFileDefinition));

    OwnerPtr<ICommandButtonDefinition> opSaveFileDefinition =
        ICommandButtonDefinition::Create(ID_CMD_SAVE_FILE, GBMP_TR(L"保存"), GBMP_TR(L"(Ctrl+S)"), ID_CMD_SAVE_FILE, L":/images/Save/48x48.png");
    IControlDefinitionLibrary::Get()->AddControlDefinition(TransferOwnership(opSaveFileDefinition));

    OwnerPtr<ICommandButtonDefinition> opSaveASFileDefinition =
        ICommandButtonDefinition::Create(ID_CMD_SAVE_FILE_AS, GBMP_TR(L"另存为"), GBMP_TR(L"另存为"), ID_CMD_SAVE_FILE_AS, L":/images/SaveAs/48x48.png");
    IControlDefinitionLibrary::Get()->AddControlDefinition(TransferOwnership(opSaveASFileDefinition));
    
    OwnerPtr<ICommandButtonDefinition> opCloseFileDefinition =
        ICommandButtonDefinition::Create(ID_CMD_CLOSE_FILE, GBMP_TR(L"关闭"), GBMP_TR(L"关闭"), ID_CMD_CLOSE_FILE, L":/images/Close/32x32.png");
    IControlDefinitionLibrary::Get()->AddControlDefinition(TransferOwnership(opCloseFileDefinition));

    OwnerPtr<ICommandButtonDefinition> opAuthenticationInfoDefinition =
        ICommandButtonDefinition::Create(ID_CMD_AUTHENTICATION, GBMP_TR(L"授权信息"), GBMP_TR(L"授权信息"), ID_CMD_AUTHENTICATION, L":/images/Authentication/32x32.png");
    IControlDefinitionLibrary::Get()->AddControlDefinition(TransferOwnership(opAuthenticationInfoDefinition));
}

void PlatformUiBuilder::BuildPages(IRibbon* pRibbon) const
{
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRibbon, L"获取RibbonBar失败", L"GDMP", L"2023-09-30");
    //文件
    OwnerPtr<IRibbonPage> opPageFile = IRibbonPage::Create(ID_CMD_NEW_FILE, GBMP_TR(L"文件"));
    opPageFile->SetPageHandler(TransferOwnership(NEW_AS_OWNER_PTR(FilePageHandler)));
    {
        OwnerPtr<IRibbonGroup> opFileGroup = IRibbonGroup::Create(ID_PAGE_FILE, GBMP_TR(L"文件"));
        //新建文件按钮
        ICommandButtonDefinition* pReferencedNewFileDefinition =
            dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_NEW_FILE));
        OwnerPtr<ICommandButtonDefinition> opNewFileDefinition = ICommandButtonDefinition::CreateReference(pReferencedNewFileDefinition);
        opFileGroup->AddButton(TransferOwnership(opNewFileDefinition));
        //打开文件按钮
        ICommandButtonDefinition* pReferencedOpenFileDefinition =
            dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_OPEN_FILE));
        OwnerPtr<ICommandButtonDefinition> opOpenFileDefinition = ICommandButtonDefinition::CreateReference(pReferencedOpenFileDefinition);
        opFileGroup->AddButton(TransferOwnership(opOpenFileDefinition));
        //关闭文件按钮
        ICommandButtonDefinition* pReferencedCloseFileDefinition =
            dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_CLOSE_FILE));
        OwnerPtr<ICommandButtonDefinition> opCloseFileDefinition = ICommandButtonDefinition::CreateReference(pReferencedCloseFileDefinition);
        opFileGroup->AddButton(TransferOwnership(opCloseFileDefinition));       
        //测试（HelloWorld）
        OwnerPtr<ICommandButtonDefinition> opTestDefinition =
            ICommandButtonDefinition::Create(ID_CMD_HELLOWORLD, GBMP_TR(L"测试"), GBMP_TR(L"测试"), ID_CMD_HELLOWORLD, L":/images/Test/48x48.png");      
        opFileGroup->AddButton(TransferOwnership(opTestDefinition));

        opPageFile->AddGroup(TransferOwnership(opFileGroup));

        OwnerPtr<IRibbonGroup> opInOutGroup = IRibbonGroup::Create(ID_GROUP_INOUT, GBMP_TR(L"导入导出"));
        //导出文件按钮 默认pdf
        OwnerPtr<ICommandButtonMenuDefinition> opExportBtn =
            ICommandButtonMenuDefinition::Create(ID_CMD_DISPATCH_EXPORT, ID_CMD_EXPORTTOPDF, GBMP_TR(L"导出"), L":/images/Export/48x48.png");
        {
            OwnerPtr<ICommandMenuItemDefinition> opExportDwg =
                ICommandMenuItemDefinition::Create(ID_CMD_EXPORTTODWG, ID_CMD_EXPORTTODWG, GBMP_TR(L"导出DWG"), GBMP_TR(L"导出DWG"), L":/images/Export/ExportDWG/48x48.png");
            opExportBtn->AddItem(TransferOwnership(opExportDwg));

            OwnerPtr<ICommandMenuItemDefinition> opExportPdf =
                ICommandMenuItemDefinition::Create(ID_CMD_EXPORTTOPDF, ID_CMD_EXPORTTOPDF, GBMP_TR(L"导出PDF"), GBMP_TR(L"导出PDF"), L":/images/Export/ExportPDF/48x48.png");
            opExportBtn->AddItem(TransferOwnership(opExportPdf));
        }
        opInOutGroup->AddButtonMenu(TransferOwnership(opExportBtn));
        //导入文件按钮
        OwnerPtr<ICommandButtonMenuDefinition> opImportBtn =
            ICommandButtonMenuDefinition::Create(ID_CMD_DISPATCH_IMPORT, L"", GBMP_TR(L"导入"), L":/images/Import/48x48.png");
        {
            OwnerPtr<ICommandMenuItemDefinition> opImportDwg =
                ICommandMenuItemDefinition::Create(ID_CMD_IMPORT_DWG, ID_CMD_IMPORT_DWG, GBMP_TR(L"导入DWG"), GBMP_TR(L"导入DWG"), L":/images/Import/CAD/48x48.png");
            opImportBtn->AddItem(TransferOwnership(opImportDwg));
            /*
                        OwnerPtr<ICommandMenuItemDefinition> opImportSkp =
                            ICommandMenuItemDefinition::Create(ID_CMD_IMPORT_SKETCHUP, ID_CMD_IMPORT_SKETCHUP, GBMP_TR(L"导入Sketchup"), GBMP_TR(L"导入Sketchup"), L":/images/apiSample.png");
                        opImportBtn->AddItem(TransferOwnership(opImportSkp));
            */
        }
        opInOutGroup->AddButtonMenu(TransferOwnership(opImportBtn));
        opPageFile->AddGroup(TransferOwnership(opInOutGroup));

        // 帮助
        OwnerPtr<IRibbonGroup> opHelpGroup = IRibbonGroup::Create(ID_GROUP_SAMPLES_HELP, GBMP_TR(L"帮助"));
        OwnerPtr<ICommandButtonDefinition> opHelpBtn =
            ICommandButtonDefinition::Create(ID_CMD_SAMPLES_HELP, GBMP_TR(L"帮助"), GBMP_TR(L"帮助"), ID_CMD_SAMPLES_HELP, L":/images/Module/Common/Help.png");
        opHelpGroup->AddButton(TransferOwnership(opHelpBtn));
        
        OwnerPtr<ICommandButtonDefinition> opAboutQtBtn =
            ICommandButtonDefinition::Create(ID_CMD_SAMPLES_ABOUT_QT, GBMP_TR(L"关于Qt"), GBMP_TR(L"关于Qt"), ID_CMD_SAMPLES_ABOUT_QT, L":/images/QtLicense/48x48.png");
        opHelpGroup->AddButton(TransferOwnership(opAboutQtBtn));
        opPageFile->AddGroup(TransferOwnership(opHelpGroup));
    }
    pRibbon->AddPage(TransferOwnership(opPageFile));

    //建模
    OwnerPtr<IRibbonPage> opPageDraw = IRibbonPage::Create(ID_PAGE_MODEL, GBMP_TR(L"基础示例"));
    opPageDraw->SetPageHandler(TransferOwnership(NEW_AS_OWNER_PTR(PageHandler)));
    {
        OwnerPtr<IRibbonGroup> opGroupElement = IRibbonGroup::Create(ID_GROUP_ELEMENT, GBMP_TR(L"构件"));

        OwnerPtr<ICommandButtonDefinition> opCreateInstanceDefinition =
            ICommandButtonDefinition::Create(ID_CMD_CREATE_INSTANCE, GBMP_TR(L"创建族"), GBMP_TR(L"创建族"), ID_CMD_CREATE_INSTANCE, L":/images/Family/48x48.png");
        opGroupElement->AddButton(TransferOwnership(opCreateInstanceDefinition));

        OwnerPtr<ICommandButtonDefinition> opDrawInstanceDefinition =
            ICommandButtonDefinition::Create(ID_LOAD_AND_CREATE_FAMILY_INSTANCE, GBMP_TR(L"加载族"), GBMP_TR(L"加载族"), ID_LOAD_AND_CREATE_FAMILY_INSTANCE, L":/images/FamilyLoad/48x48.png");
        opGroupElement->AddButton(TransferOwnership(opDrawInstanceDefinition));      

        OwnerPtr<ICommandButtonDefinition> opSetViewOptionDefinition =
            ICommandButtonDefinition::Create(ID_CMD_SETVIEWOPTION, GBMP_TR(L"视图显示"), GBMP_TR(L"视图显示"), ID_CMD_SETVIEWOPTION, L":/images/UiSetting/48x48.png");
        opGroupElement->AddButton(TransferOwnership(opSetViewOptionDefinition));

        OwnerPtr<ICommandButtonDefinition> opCreateViewportDefinition =
            ICommandButtonDefinition::Create(ID_CMD_CREATE_VIEWPORT, GBMP_TR(L"创建视口"), GBMP_TR(L"创建视口"), ID_CMD_CREATE_VIEWPORT, L":/images/View/视口.png");
        opGroupElement->AddButton(TransferOwnership(opCreateViewportDefinition));

        opPageDraw->AddGroup(TransferOwnership(opGroupElement));

        OwnerPtr<IRibbonGroup> opViewGroup = IRibbonGroup::Create(ID_GROUP_UISETTINGS, GBMP_TR(L"界面"));
        DBG_WARN_AND_RETURN_VOID_UNLESS(opViewGroup, L"opViewGroup为空", L"GDMP", L"2023-10-20");

        {
            OwnerPtr<ICommandButtonDefinition> opPropertyButtonDef = ICommandButtonDefinition::Create(COMMAND_SHOW_HIDE_PROPERTY_PALETTE, GBMP_TR(L"属性面板"),
                GBMP_TR(L"属性面板"), COMMAND_SHOW_HIDE_PROPERTY_PALETTE, L":/images/View/PropertyPanel.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opPropertyButtonDef, L"opPropertyButtonDef为空", L"GDMP", L"2023-09-30");
            opViewGroup->AddButton(TransferOwnership(opPropertyButtonDef));

            OwnerPtr<ICommandButtonDefinition> opResButtonDef = ICommandButtonDefinition::Create(COMMAND_SHOW_HIDE_RESMANAGER, GBMP_TR(L"资源管理器"),
                GBMP_TR(L"资源管理器"), COMMAND_SHOW_HIDE_RESMANAGER, L":/images/View/ResManagerPanel.png");
            DBG_WARN_AND_RETURN_VOID_UNLESS(opResButtonDef, L"opResButtonDef为空", L"GDMP", L"2023-09-30");
            opViewGroup->AddButton(TransferOwnership(opResButtonDef));
        }
        opPageDraw->AddGroup(TransferOwnership(opViewGroup));
    }
    pRibbon->AddPage(TransferOwnership(opPageDraw));

    // 模块实验室
    OwnerPtr<IRibbonPage> opPageModule = IRibbonPage::Create(ID_PAGE_MODULE, GBMP_TR(L"API实验室"));
    opPageModule->SetPageHandler(TransferOwnership(NEW_AS_OWNER_PTR(PageHandler)));
    {
        OwnerPtr<IRibbonGroup> opModuleGroup = IRibbonGroup::Create(ID_GROUP_MODULE, GBMP_TR(L"GDMP模块"));
        DBG_WARN_AND_RETURN_VOID_UNLESS(opModuleGroup, L"opModuleGroup为空", L"GDMP", L"2023-10-20");
        opPageModule->AddGroup(TransferOwnership(opModuleGroup));
}
    pRibbon->AddPage(TransferOwnership(opPageModule));

}

void PlatformUiBuilder::BuildLeftQuickAccessBar(gcmp::IRibbon* pRibbon) const
{
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRibbon, L"获取RibbonBar失败", L"GDMP", L"2023-09-30");
    //左边快捷访问工具栏
    IRibbonQuickAccessBar* pLeftQuickAccessBar = pRibbon->GetLeftQuickAccessBar();
    DBG_WARN_AND_RETURN_VOID_UNLESS(pLeftQuickAccessBar, L"获取左快捷访问栏失败", L"GDMP", L"2023-09-30");
    pLeftQuickAccessBar->SetQuickAccessBarHandler(TransferOwnership(NEW_AS_OWNER_PTR(QuickAccessBarHandler)));

    //新建文件按钮
    ICommandButtonDefinition* pReferencedNewFileDefinition =
        dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_NEW_FILE));
    OwnerPtr<ICommandButtonDefinition> opNewFileDefinition = ICommandButtonDefinition::CreateReference(pReferencedNewFileDefinition);
    pLeftQuickAccessBar->AddButton(TransferOwnership(opNewFileDefinition));
    //打开文件按钮
    ICommandButtonDefinition* pReferencedOpenFileDefinition =
        dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_OPEN_FILE));
    OwnerPtr<ICommandButtonDefinition> opOpenFileDefinition = ICommandButtonDefinition::CreateReference(pReferencedOpenFileDefinition);
    pLeftQuickAccessBar->AddButton(TransferOwnership(opOpenFileDefinition));
    //保存文件按钮
    ICommandButtonDefinition* pReferencedSaveFileDefinition =
        dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_SAVE_FILE));
    OwnerPtr<ICommandButtonDefinition> opSaveFileDefinition = ICommandButtonDefinition::CreateReference(pReferencedSaveFileDefinition);
    pLeftQuickAccessBar->AddButton(TransferOwnership(opSaveFileDefinition));
    //另存文件按钮
    ICommandButtonDefinition* pReferencedSaveFileAsDefinition =
        dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_SAVE_FILE_AS));
    OwnerPtr<ICommandButtonDefinition> opSaveFileAsDefinition = ICommandButtonDefinition::CreateReference(pReferencedSaveFileAsDefinition);
    pLeftQuickAccessBar->AddButton(TransferOwnership(opSaveFileAsDefinition));
    //撤销
    OwnerPtr<ICommandButtonDefinition> opUndoDefinition =
        ICommandButtonDefinition::Create(ID_CMD_UNDO, GBMP_TR(L"撤销"), GBMP_TR(L"撤销(Ctrl+Z)"), ID_CMD_UNDO, L":/images/UiPlatform/Undo.png");
    pLeftQuickAccessBar->AddButton(TransferOwnership(opUndoDefinition));
    //重做
    OwnerPtr<ICommandButtonDefinition> opRedoDefinition =
        ICommandButtonDefinition::Create(ID_CMD_REDO, GBMP_TR(L"重做"), GBMP_TR(L"重做(Ctrl+Y)"), ID_CMD_REDO, L":/images/UiPlatform/Redo.png");
    pLeftQuickAccessBar->AddButton(TransferOwnership(opRedoDefinition));
    //授权按钮
    ICommandButtonDefinition* pReferencedAuthenticationInfoDefinition =
        dynamic_cast<ICommandButtonDefinition*>(IControlDefinitionLibrary::Get()->GetControlDefinition(ID_CMD_AUTHENTICATION));
    OwnerPtr<ICommandButtonDefinition> opAuthenticationInfoDefinition = ICommandButtonDefinition::CreateReference(pReferencedAuthenticationInfoDefinition);
    pLeftQuickAccessBar->AddButton(TransferOwnership(opAuthenticationInfoDefinition));
}


void PlatformUiBuilder::BuildRightQuickAccessBar(gcmp::IRibbon* pRibbon) const
{
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRibbon, L"获取RibbonBar失败", L"GDMP", L"2023-09-30");
    //右边快捷访问工具栏
    IRibbonQuickAccessBar* pRightQuickAccessBar = pRibbon->GetRightQuickAccessBar();
    DBG_WARN_AND_RETURN_VOID_UNLESS(pRightQuickAccessBar, L"获取右快捷访问栏失败", L"GDMP", L"2023-09-30");
    pRightQuickAccessBar->SetQuickAccessBarHandler(TransferOwnership(NEW_AS_OWNER_PTR(QuickAccessBarHandler)));
    //OwnerPtr<ICommandButtonDefinition> opCommandButton = ICommandButtonDefinition::Create(COMMAND_SYSTEM_HELP,
    //    L"系统信息", L"显示系统显示", COMMAND_SYSTEM_HELP, L":images/Icon_system_help.png");
    //pRightQuickAccessBar->AddButton(TransferOwnership(opCommandButton));

}

void PlatformUiBuilder::BuildStatusBar(IMainWindow* pMainWnd) const
{
    DBG_WARN_AND_RETURN_VOID_UNLESS(pMainWnd, L"获取主窗口失败", L"GDMP", L"2023-09-30");
    IStatusBar* pStatusBar = pMainWnd->GetStatusBar();
    DBG_WARN_AND_RETURN_VOID_UNLESS(pStatusBar, L"获取状态栏失败", L"GDMP", L"2023-09-30");

    OwnerPtr<ILabelDefinition> opLabelDefineMousePosition = ILabelDefinition::Create(STATUSBAR_MOUSE_POSITON, L"位置", L"鼠标位置");
    OwnerPtr<IStatusBarPanel> opStatusBarPanelMousePosition = IStatusBarPanel::Create(STATUSBAR_MOUSE_POSITON, 600);
    opStatusBarPanelMousePosition->AddLabel(TransferOwnership(opLabelDefineMousePosition));
    pStatusBar->AppendPanel(TransferOwnership(opStatusBarPanelMousePosition), StatusBarAlignment::Left);

    OwnerPtr<ILabelDefinition> opLabelDefineElementCount = ILabelDefinition::Create(STATUSBAR_SELECTION_COUNT, L"构件数量", L"选中构件数量");
    OwnerPtr<IStatusBarPanel> opStatusBarPanelElementCount = IStatusBarPanel::Create(STATUSBAR_SELECTION_COUNT, 100);
    opStatusBarPanelElementCount->AddLabel(TransferOwnership(opLabelDefineElementCount));
    pStatusBar->AppendPanel(TransferOwnership(opStatusBarPanelElementCount), StatusBarAlignment::Right);

    OwnerPtr<ILabelDefinition> opLabelPrompt = ILabelDefinition::Create(ID_STATUS_BAR_LABEL_PROMPT,
        GBMP_TR(L"就绪"), GBMP_TR(L"即时信息"));
    OwnerPtr<IStatusBarPanel> opStatusBarPanelPrompt = IStatusBarPanel::Create(ID_STATUS_BAR_PANEL_PROMPT);
    opStatusBarPanelPrompt->AddLabel(TransferOwnership(opLabelPrompt));
    pStatusBar->AppendPanel(TransferOwnership(opStatusBarPanelPrompt), StatusBarAlignment::Left);
}
